//
//  KEPViewController.m
//  Demo
//
//  Created by bupterambition on 09/20/2017.
//  Copyright (c) 2017 bupterambition. All rights reserved.
//

#import "KEPViewController.h"
#import "KEPTest.h"
#import "GPBMessage.h"
#import <TTRoute/TTRoute.h>
//#import "TTRoute.h"


@interface KEPViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableview;

@end

@implementation KEPViewController

- (void)viewDidLoad
{
    KEPTest *test = [KEPTest new];
    [test test];
    [super viewDidLoad];
    
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.tableview.contentInset = UIEdgeInsetsMake(-50, 0, 0, 0);
    
    [UIView animateWithDuration:3 animations:^{
        self.tableview.contentOffset = CGPointMake(0, 0);
    } completion:^(BOOL finished) {
        if (finished) {
            [UIView animateWithDuration:3 animations:^{
                self.tableview.contentOffset = CGPointMake(0, 50);
            } completion:^(BOOL finished) {
            }];
        }
    }];
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    if (scrollView.contentOffset.y <=0) {
        self.tableview.contentInset = UIEdgeInsetsZero;
    }else {
        self.tableview.contentInset = UIEdgeInsetsMake(-50, 0, 0, 0);
    }
    
    NSLog(@"%@",NSStringFromCGPoint(scrollView.contentOffset));
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    if (indexPath.row == 0) {
        cell.backgroundColor = [UIColor redColor];
    }
    return cell;
}


@end
